package IC.lir.instructions;

import java.util.HashMap;

public class Register extends Operand {
	
	private static HashMap<Integer,Register> auxilary = new HashMap<Integer,Register>();
	private int index;
	
	
	//C'tor
	public Register() {
		this.index = 0;
		auxilary.put(this.index, this);
	}
	
	//C'tor
	protected Register(int index) {
		this.index = index;
		auxilary.put(this.index, this);
	}
	
	public Register getSuccessor() {
		if (auxilary.containsKey(index+1))
			return auxilary.get(index+1);
		return new Register(index+1);
	}
	
	@Override
	public String toString() {
		return "R" + index;
	}
}